package com.freshmarket.fresh.controller;

import com.freshmarket.fresh.mapper.ProductMapper;
import com.freshmarket.fresh.entity.Product;
import com.freshmarket.fresh.vo.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class ProductController {
    @Autowired(required = false)
    ProductMapper mapper;

    @RequestMapping("/product/selectAll")
    public JsonResult select(){
        System.out.println("开始获取商品列表");
        HashMap map = new HashMap();
        map.put("total",mapper.selectCount());
        map.put("items",mapper.selectList());
        return JsonResult.success(map);
    }


}
